/*
 * @Author: [wcy]
 * @Date: 2021-12-06 13:43:58
 * @LastEditors: [wcy]
 * @LastEditTime: 2021-12-15 11:29:14
 * @Description: 
 */
// pages/order/index.js
import {
  request
} from "../../request/index.js"
Page({


  data: {
    tabs:[
      {
        id:0,
        value:"全部",
        isActive:true
      },
      {
        id:1,
        value:"待付款", 
        isActive:false
      },
      {
        id:2,
        value:"待发货",
        isActive:false
      },
      {
        id:3,
        value:"退货/退款",
        isActive:false
      },
    ],

  },

  onShow(options) {
    
    let pages = getCurrentPages();
    // 数组中 索引最大的页面就是当前页面
    let currentPage=pages[pages.length-1]
    console.log(currentPage.options);
    // 获取url上的type参数
    const {type}=currentPage.options
    this.getOrders(type)
  },
  // 获取订单列表数据

  async getOrders(type){
    const res = await request({url:"/my/orders/all",data:type})
    console.log(res);
  },
  handleTabsItemChange(e){
    // 获取被点击 的标题的索引
    const {index}=e.detail;
    let {tabs}=this.data;
    tabs.forEach((v,i)=>i===index?v.isActive=true:v.isActive=false);
    this.setData({
      tabs
    })
  },
})